package org.springframework.learn.beans.note;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class MyAnnotationConfigApplicationContext extends AnnotationConfigApplicationContext {

	public MyAnnotationConfigApplicationContext(Class<?>... componentClasses) {
		super(componentClasses);
	}


	// 重写初始化属性
	@Override
	protected void initPropertySources() {
		// 设置必须要有这个环境变量
		getEnvironment().setRequiredProperties("username");
		// AbstractApplicationContext.prepareRefresh
		// getEnvironment().validateRequiredProperties();
		// AbstractEnvironment.validateRequiredProperties
		// AbstractPropertyResolver.validateRequiredProperties
		// MissingRequiredPropertiesException ex = new MissingRequiredPropertiesException();
		//		for (String key : this.requiredProperties) {
		//			if (this.getProperty(key) == null) {
		//				ex.addMissingRequiredProperty(key);
		//			}
		//		}
		//		if (!ex.getMissingRequiredProperties().isEmpty()) {
		//			throw ex;
		//		}
	}
}
